<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//理财平台表
class Sort_record_model extends CI_Model{
    function __construct() {
        parent::__construct();
        $this->table = 'sort_record';
    }
    function get_count($where){
        $this->db->select("*");
        $this->db->from($this->table);
        $this->db->where($where);
        $this->db->order_by('sort','desc');
        return $this->db->get()->num_rows();
    }
    function get_list($where,$page,$limit){
        $this->db->select("*,".$this->plat_baseinfo_table.".company_bg_type");
        $this->db->from($this->table);
        $this->db->join($this->plat_baseinfo_table,  $this->table.".name_en = ".$this->plat_baseinfo_table.".plat_en" ,"left");
        $this->db->where($where);
        $this->db->order_by('sort','desc');
        $this->db->limit($limit, $page);
        return $this->db->get()->result_array();
    }
    //没有分页的所有palt列表
    function get_all_list($where=array()){
        $this->db->select("*");
        $this->db->from($this->table);
        $this->db->where($where);
        $this->db->order_by("sort_score","desc");
        return $this->db->get()->result_array();
    }
    //更新plat表
    function update_plat($data,$id){
        return $this->db->where('id',$id)->update($this->table, $data);
    }

    function insert_sort_record($data){
        $this->db->insert($this->table, $data);
        if($this->db->affected_rows()){
            return $this->db->insert_id();
        }else{
            return 0;
        }
    }


}
